
<?php require_once '../model/model.php';
$id = $_GET['id'];
$query = "SELECT * FROM works WHERE id='$id'";
$sql = mysql_query($query);

while ($result = mysql_fecth_aray($sql)) {
    $id = $result['id'];
    $title = $result['name'];
    $img_path = $result['image'];
    ?>
    <form>
        <input type="text" name="title" <?
    if ($_POST['name'])
        echo $_POST['name'];
    else
        echo $title;
    ?> />
        <input type="file" name="filename" />
        <input type="submit" value="submit" name="submit" />
    </form>
    <?php
    if ($_POST['submit']) {
        if ($_FILES['filename']['name']) {
            $file_name = $_FILES['filename']['name'];
            $file_path = $_FILES['filename']['tmp_name'];
            $new_path = "public/images/" . $file_name;
            $img_path = $new_path;
            $uploaded_file = move_uploaded_file($file_path, $new_path);
        } else {
            $img_path = $img_path;
        }
    }
}
